<?php
/**
 *
 * PHP 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       Cake.Console.Templates.default.views
 * @since         CakePHP(tm) v 1.2.0.5234
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
?>
<div class="page">
	<div class="page-header">
		<h2><?php echo "<?php echo __('{$pluralHumanName}');?>";?>
		<small><?php echo "<?php echo __('{$pluralHumanName}');?>";?></small></h2>
		<div class="page-header-fields">
			<?php echo "\t\t<?php echo \$this->Html->link('<i class=\"icon-th-list icon-white\"></i> '.__('List').' '.__('{$pluralHumanName}'), array('action' => 'index'), array('escape' => false, 'class' => 'btn btn-primary')); ?>\n"; ?>
			<?php echo "\t\t<?php echo \$this->Html->link('<i class=\"icon-plus icon-white\"></i>'.__('Add').' '.__('{$pluralHumanName}'), array('action' => 'add'), array('escape' => false, 'class' => 'btn btn-primary')); ?>\n"; ?>
		</div>
	</div>
	<div class="page-content">
		<?php echo "<?php echo \$this->Form->create('{$modelClass}', array('class' => 'form-horizontal'));?>\n";?>
			<fieldset>
				<legend><?php printf("<?php echo __('%s %s'); ?>", Inflector::humanize($action), $singularHumanName); ?></legend>
<?php
				foreach ($fields as $field) {
					if (strpos($action, 'add') !== false && $field == $primaryKey) {
						continue;
					} elseif (!in_array($field, array('created', 'modified', 'updated'))) {
						echo "\t\t\t\t<div class=\"control-group\">\n";
						echo "\t\t\t\t\t<?php echo \$this->Form->Label('{$field}', '{$field}', array('class' => 'control-label'));\t?>\n";
						echo "\t\t\t\t\t<div class=\"controls\">\n";
						echo "\t\t\t\t\t\t<?php echo \$this->Form->input('{$field}', array('label' => false, 'div' => false));\t?>\n";
						echo "\t\t\t\t\t\t<p class=\"help-block\">Breve comentario sobre o campo</p>\n";
						echo "\t\t\t\t\t</div>\n";
						echo "\t\t\t\t</div>\n";
					}
				}
				if (!empty($associations['hasAndBelongsToMany'])) {
					foreach ($associations['hasAndBelongsToMany'] as $assocName => $assocData) {
						echo "\t\t<?php echo \$this->Form->input('{$assocName}');\t?>\n";
					}
				}
		?>
				<div class="form-actions">
<?php 				echo "\t\t\t\t\t<?php echo \$this->Form->submit(__('Save'), array('div' => false, 'class' => 'btn btn-primary')); \t?>\n"; ?>
	          	</div>
			</fieldset>
		<?php
			echo "<?php echo \$this->Form->end();?>\n";
		?>
	</div>
   <div class="page-footer"></div>
</div>
<div class="actions">
	<h3><?php echo "<?php echo __('Actions'); ?>"; ?></h3>
	<ul>

<?php if (strpos($action, 'add') === false): ?>
		<li><?php echo "<?php echo \$this->Form->postLink(__('Delete'), array('action' => 'delete', \$this->Form->value('{$modelClass}.{$primaryKey}')), null, __('Are you sure you want to delete # %s?', \$this->Form->value('{$modelClass}.{$primaryKey}'))); ?>";?></li>
<?php endif;?>
		<li><?php echo "<?php echo \$this->Html->link(__('List " . $pluralHumanName . "'), array('action' => 'index'));?>";?></li>
<?php
		$done = array();
		foreach ($associations as $type => $data) {
			foreach ($data as $alias => $details) {
				if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
					echo "\t\t<li><?php echo \$this->Html->link(__('List " . Inflector::humanize($details['controller']) . "'), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
					echo "\t\t<li><?php echo \$this->Html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "'), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
					$done[] = $details['controller'];
				}
			}
		}
?>
	</ul>
</div>
